package com.bjwl.web;

import com.bjwl.pojo.Bsadmin;
import com.bjwl.pojo.Proper;
import com.bjwl.pojo.Staff;
import com.bjwl.pojo.dto.BsadminPowerDto;
import com.bjwl.service.BsadminPowerService;
import com.bjwl.service.ProperService;
import com.bjwl.service.StaffService;
import com.bjwl.web.contrlller.branchstore.BusinessController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.Calendar;
import java.util.Date;

/**
 * @Author: dzx
 * @Date:Create：in 2020/4/10 20:24
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
public class BrUiController {

    @Autowired
    private BsadminPowerService bsadminPowerService;

    @Autowired
    private ProperService properService;

    @Autowired
    private BusinessController controller;
    @RequestMapping("/br/{path}")
    public String mainFrom(@PathVariable String path, HttpSession httpSession, Model model){
        if(path.equals("index")){
            Bsadmin bsadmin =  (Bsadmin)httpSession.getAttribute("bsadmin1");
            BsadminPowerDto bsadminPowerById = bsadminPowerService.findBsadminPowerById(bsadmin.getId());
            httpSession.setAttribute("power",bsadminPowerById);
            Calendar rightNow = Calendar.getInstance();
            // 获取月
            int month = rightNow.get(Calendar.MONTH)+1;
            Proper properById = properService.findProperById(month);
            model.addAttribute("proper",properById);
        }
        System.out.println("解析页面");
        return "branch_oa/"+path;
    }

}
